package com.jlnk.stockdemo.bean;

import com.google.gson.annotations.SerializedName;

import java.util.ArrayList;
import java.util.List;

public class BondsListResponse {

    @SerializedName("request_id")
    private String requestId;

    @SerializedName("code")
    private int code;

    @SerializedName("data")
    private BondsListResponse.Data data;

    @SerializedName("msg")
    private String msg;

    public String getRequestId() {
        return requestId;
    }

    public int getCode() {
        return code;
    }

    public BondsListResponse.Data getData() {
        return data;
    }

    public String getMsg() {
        return msg;
    }

    public static class Data {
        @SerializedName("fields")
        private List<String> fields;

        @SerializedName("items")
        private List<List<String>> items;

        @SerializedName("has_more")
        private boolean hasMore;

        @SerializedName("count")
        private int count;

        private List<Bonds> bondsList;

        public List<String> getFields() {
            return fields;
        }

        public List<List<String>> getItems() {
            return items;
        }

        public boolean isHasMore() {
            return hasMore;
        }

        public int getCount() {
            return count;
        }

        public List<Bonds> getBondsList() {
            bondsList = new ArrayList<>();
            int tsCodeIndex, bond_short_nameIndex, stk_short_nameIndex, remain_sizeIndex, coupon_rateIndex, add_rateIndex;
            tsCodeIndex = bond_short_nameIndex = stk_short_nameIndex = remain_sizeIndex = coupon_rateIndex = add_rateIndex =0;
            for (int i = 0; i < fields.size(); i++) {
                switch (fields.get(i)) {
                    case "ts_code" :
                        tsCodeIndex = i;
                        break;
                    case "bond_short_name" :
                        bond_short_nameIndex = i;
                        break;
                    case "stk_short_name" :
                        stk_short_nameIndex = i;
                        break;
                    case "remain_size" :
                        remain_sizeIndex = i;
                        break;
                    case "coupon_rate" :
                        coupon_rateIndex = i;
                        break;
                    case "add_rate" :
                        add_rateIndex = i;
                        break;
                }
            }
            for (int j = 0; j < items.size(); j++) {
                Bonds bonds = new Bonds();
                bonds.setTsCode(items.get(j).get(tsCodeIndex));
                bonds.setBond_short_name(items.get(j).get(bond_short_nameIndex));
                bonds.setStk_short_name(items.get(j).get(stk_short_nameIndex));
                bonds.setRemain_size(items.get(j).get(remain_sizeIndex));
                bonds.setCoupon_rate(items.get(j).get(coupon_rateIndex));
                bonds.setAdd_rate(items.get(j).get(add_rateIndex));
                bondsList.add(bonds);
            }
            return bondsList;
        }

        public static class Bonds {
            private String tsCode;
            private String bond_short_name;
            private String stk_short_name;
            private String remain_size;
            private String coupon_rate;
            private String add_rate;

            public String getTsCode() {
                return tsCode;
            }

            public void setTsCode(String tsCode) {
                this.tsCode = tsCode;
            }

            public String getBond_short_name() {
                return bond_short_name;
            }

            public void setBond_short_name(String bond_short_name) {
                this.bond_short_name = bond_short_name;
            }

            public String getStk_short_name() {
                return stk_short_name;
            }

            public void setStk_short_name(String stk_short_name) {
                this.stk_short_name = stk_short_name;
            }

            public String getRemain_size() {
                return remain_size;
            }

            public void setRemain_size(String remain_size) {
                this.remain_size = remain_size;
            }

            public String getCoupon_rate() {
                return coupon_rate;
            }

            public void setCoupon_rate(String coupon_rate) {
                this.coupon_rate = coupon_rate;
            }

            public String getAdd_rate() {
                return add_rate;
            }

            public void setAdd_rate(String add_rate) {
                this.add_rate = add_rate;
            }
        }
    }
}
